import yaml

values = {
    "name": "Tom Smith",
    "age": 37,
    "spouse": {
        "name": "Jane Smith",
        "age": 25
    },
    "children": [
        {
            "name": "Jimmy Smith",
            "age": 15
        },
        {
            "name": "Jenny Smith",
            "age": 12
        }
    ]
}

# with open('.\my_test.yaml') as f:
#     my_values = yaml.load(f)
# print(my_values)

# with open('.\create_org_cases.yaml', encoding='utf-8') as f:
#     case_datas = yaml.safe_load(f)
# print(case_datas)

# with open('.\demo01.yaml', encoding="utf-8") as f:
#     print(yaml.safe_load(f))

# with open('.\demo02.yaml', encoding="utf-8") as f:
#     print(yaml.safe_load(f))

# with open('.\demo03.yaml', encoding="utf-8") as f:
#     value = yaml.safe_load(f)
# print(value)
# print(value.get('str'))

# with open('.\demo04.yaml', encoding='utf-8') as f:
#     value = yaml.safe_load(f)
#     print(value.get("str1"))
#     print("---------------------------------------")
#     print(value.get("str2"))

# with open('.\demo05.yaml', encoding='utf-8') as f:
#     print(yaml.safe_load(f))

# with open('.\demo06.yaml', encoding='utf-8') as f:
#     print(yaml.safe_load(f))

with open('.\demo07.yaml', encoding='utf-8') as f:
    value = yaml.safe_load_all(f)  # 一个文件中存在多段yaml数据时，全部读取，读取出来是一个可迭代对象
    print(value)
    print(value)
    for i in value:
        print(i)